package com.hzz.web.app.examine;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.github.pagehelper.PageInfo;
import com.hzz.api.examine.IExamineMainTargetService;
import com.hzz.dto.examine.ExamineMainTargetDto;
import com.hzz.framework.PageUtil;
import com.hzz.framework.Response;
import com.hzz.framework.dto.PageDto;
import com.hzz.framework.util.CommonConstant;
import com.hzz.framework.web.controller.BaseController;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;

@Api(tags = "目标考核-主要目标")
@RestController
@Slf4j
public class ApiExamineMainTargetController extends BaseController {
	@Autowired
	IExamineMainTargetService examineMainTargetService;
	static final String acPrefix = "/api/examine/examineMainTarget/";

	@ApiOperation(value = "总体/年度目标列表")
	@RequestMapping(method = RequestMethod.GET, value = acPrefix + "page/{pageNum}")
	public Response<PageDto<List<ExamineMainTargetDto>>> page(@PathVariable("pageNum") Integer pageNum,
			@RequestParam(required = true, name = "type") @ApiParam("目标类型（1年度目标；2总体目标）") Integer type) {
		log.info("list.........");
		Response result = new Response();
		try {
			ExamineMainTargetDto dto = new ExamineMainTargetDto();
			dto.setType(type);
			dto.setPageSize(CommonConstant.PAGEROW_DEFAULT_COUNT);
			dto.setPageNum(pageNum);
			PageInfo page = examineMainTargetService.findDataIsPage(dto);

			result.data = PageUtil.copy(page);
		} catch (Exception e) {
			result = Response.error(e.getMessage());
		}
		return result;
	}
}